# _*_coding : utf-8 _*_
# @Time : 2025/11/3 10:10
# @Author : Eavan
# @filename : api.py
from http.client import responses

import requests                       # 导入requests模块进行发起接口请求
from cms_config.config import *       # 导入config中的所有内容
import json

## Gitee更改

# 第三步：我们需要对测试的接口进行封装成一个可供调用的功能接口方法
# 1、在这个包我们需要对这些接口封装成一个类，以便后面的调用
# 2、这里需要发起接口请求，需要用到requests包，做请求方法的数据
# 3、同样要把config中所有的数据导到这个包，作为此包的数据连接

class Cms(object):

    def __init__(self):     # 初始化参数，session表示每个接口都保持在一个对话中
        self.session = requests.session()

    # 封装登录接口
    def login(self):
        response = self.session.post(url=login_url,data=login_data,headers=login_headers)
        return response.json()

    def query_user_list(self):
        response = self.session.post(url=queryUserList_url,data=queryUserList_data,headers=queryUserList_headers)
        return response.json()

    def adduser(self):
        response = self.session.post(url=addUser_url,data=addUser_data,headers=addUser_headers)
        return response.json()

    def change_pwd(self):
        response = self.session.post(url=changePwd_url,data=changePwd_data,headers=changePwd_headers)
        return response.json()

    def delete_user(self):
        response = self.session.post(url=delete_user_url,data=delete_user_data,headers=delete_user_headers)
        return response.json()

    def edit_user(self):
        response = self.session.post(url=edit_user_url,data=edit_user_data,headers=edit_user_headers)
        return response.json()

    def user_StopUse(self):
        response = self.session.post(url=user_stop_use_url,data=user_stop_use_data,headers=user_stop_headers)
        return response.json()

    def user_startUse(self):
        response = self.session.post(url=userStart_url,data=userStart_data,headers=userStart_headers)
        return response.json()

    def delete_more(self):
        response = self.session.post(url=delete_more_url,data=delete_more_data,headers=delete_more_headers)
        return response.json()

    def login_mistake(self):
        response = self.session.post(url=login_mistake_url,data=login_mistake_data,headers=login_mistake_headers)
        return response.json()

if __name__ == '__main__':
    nasa = Cms()
    print(nasa.login())
    print(nasa.query_user_list())
    print(nasa.adduser())
    print(nasa.change_pwd())
    print(nasa.delete_user())
    print(nasa.edit_user())
    print(nasa.user_StopUse())
    print(nasa.user_startUse())
    print(nasa.delete_more())
    print(nasa.login_mistake())
